#include <iostream>
#include <iomanip>
using namespace std;

int grade[10][10];
int m,n;

struct Score 
{
    int No;
    double ave;
};
struct Score score[10];

int main()
{
    cin>>m>>n;
    for(int row = 0; row<m; row++)
    {
        for(int col =0; col<n; col++)
        {
            cin >>grade[row][col];
        }
    }
    
    for(int row = 0; row<m; row++)
    {
        int sum =0;
        int min =grade[row][0];
        int max =grade[row][0];
        for(int col =0; col<n; col++)
        {
            sum = sum + grade[row][col];
            if(min>grade[row][col])
                min = grade[row][col];
            if(max<grade[row][col])
                max = grade[row][col];
        }
        score[row].No = row+1;
        score[row].ave = (double)(sum -max -min)/(n-2);
    }
    
   
    while(true)
    {
        bool ifSwap = false;
        for(int i = 0;i<m-1; i++)
        {
            if(score[i].ave < score[i+1].ave)
            {
                Score temp = score[i];
                score[i] = score[i+1];
                score[i+1] = temp;
                ifSwap = true;
            }
        }
        if(!ifSwap) break;
    }
    for(int i = 0; i<m; i++)
        cout<<setw(3)<<score[i].No;
}